/*
 * StackInt.c
 *
 *  Created on: Jan 29, 2012
 *      Author: Georgios
 */


#include <stdio.h>
#include <string.h>
//#include <conio.h>

#include "StackPimitiveDataTypes.h"
#include "MyStack.h"

int StackInt(int maxsize)
{
    int x=0;

    stack_t mystack;
    stackElement_t *stackelem;

    int elems[maxsize];
    int *traverseint;

    for (x=0;x<maxsize;x++) {
    	elems[x] = (x+1)*356;
    }

    printf("\n");
    printf("\n---------------------------------\n");
    printf("\nStack Use - Int types\n");
    printf("\n---------------------------------\n");

    if (!StackInit(&mystack, maxsize)) {
    	return 0;
    }

    printf("\nPushed elements are: ");
    traverseint = elems;
    for (x=0; x < maxsize; x++) {
    	printf("< %d >", *traverseint);
		if (!StackPush(&mystack, traverseint++)) {
			printf("\n Warning: Stack is full ");
		}
    }


    printf("\nPopped elements are: ");

    while (!StackIsEmpty(&mystack)) {
    	stackelem = StackPop(&mystack);
    	traverseint = *stackelem;
    	if (NULL != stackelem) {
    		printf("< %d >", *traverseint);
    	}
    }

    StackDestroy(&mystack);
    return 0;
}
